package com.example.icampusevent;

import java.util.ArrayList;

import android.app.Activity;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.text.Layout;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.CheckBox;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.TextView;

public class EventCategoryAdapter extends BaseAdapter {
	
	private Activity activity;
	private String[] categories = {"ALL", "MUSIC", "SPORTS", "FILM", "WORKSHOP", "ACDAMIC", 
    		"EXHIBIT", "OTHER"};
	private ArrayList<CheckBox> boxes = null;
	private int[] colors = {0x001434, 0x900F00, 0x3C270F, 0x11230A,
			        0x5F416D, 0x461300, 0x72135D, 0x4E0E00};

    public EventCategoryAdapter(Activity _activity) {
        this.activity = _activity;
        this.boxes = new ArrayList<CheckBox>();
    }
	
	public int getCount() {
		return categories.length;
	}

	public Object getItem(int position) {
		return boxes.get(position);
	}

	public long getItemId(int position) {
		return 0;
	}

	public View getView(int position, View convertView, ViewGroup parent) {
		View vi = convertView;
		if(convertView==null) {
			LayoutInflater inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			vi = inflater.inflate(R.layout.event_category_list_row_layout, null);
			TextView category = (TextView)(vi.findViewById(R.id.category_name));
			category.setText(categories[position]);
			CheckBox checkBox = (CheckBox)(vi.findViewById(R.id.select_category_check_box));
			checkBox.setBackgroundColor(colors[position]);
			boxes.add(checkBox);
		}
        return vi;
	}
}
